//
//  ViewTestOrderController.m
//  MIDI
//
//  Created by E.M.Game on 15/10/9.
//  Copyright (c) 2015年 QXSX. All rights reserved.
//

#import "ViewTestOrderController.h"
#import "AppConfig.h"
#import "UIViewController+NavItem.h"
#import "ViewTestOrderCell.h"
#import "ReciveCertificateModel.h"

@interface ViewTestOrderController ()<UITableViewDelegate , UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *myTableView;

@end

@implementation ViewTestOrderController

@synthesize data;

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self configNavigationItem];
    
    [self.myTableView reloadData];
}

-(void) configNavigationItem
{
    [self.navigationController.navigationBar setBarTintColor:MIDIColorOfNavigationBar];
    self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
    self.navigationItem.title = @"查看订单详情";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor, [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1.0],UITextAttributeTextShadowColor,[UIFont fontWithName:@"Hiragino Sans GB" size:18.0],UITextAttributeFont,nil]];
    
    [self configNavigationBackAction:^{
        
        [self.navigationController popViewControllerAnimated:YES];
    }];
    
}

#pragma mark tableView datasource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [self.data count];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 84;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ViewTestOrderCell *cell = nil;
    NSString *identifier = @"ViewTestOrderCell";
    cell = [self.myTableView dequeueReusableCellWithIdentifier:identifier];
    if(cell == nil)
    {
        cell = [ViewTestOrderCell loadFromXib];
    }
    [self configCell:indexPath.row cell:cell];
    return cell;
}

#pragma mark - Table View Delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    if ([self.data count])
//    {
//        ReciveCertificateModel *model =
//        (ReciveCertificateModel *)[self.data objectAtIndex:indexPath.row];
    
        //TODO:wanglei
//        model.courier_order_num
        
//        UIViewController * vc = [[UIViewController alloc]init];
//        UIWebView *webView = [[UIWebView alloc]initWithFrame:self.view.bounds];
//        
//        [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://blog.csdn.net/chaoyuan899/article/details/38390507"]]];
//        [vc.view addSubview:webView];
//        [self.navigationController pushViewController:vc animated:YES];
//    }
}

- (void)configCell :(NSInteger)row cell:(ViewTestOrderCell *) mycell
{
    if ([self.data count])
    {
        ReciveCertificateModel *model =
            (ReciveCertificateModel *)[self.data objectAtIndex:row];
        if (model)
        {
            mycell.nameLb.text = model.courier_name;
            mycell.numberLb.text = model.courier_order_num;
        }
    }
}


@end





















